package com.wangzhen.codebase.thread.state;

public class ThreadStateDemo {

    public static void main(String[] args) throws InterruptedException {

        Thread t1 = new Thread(() -> {
            try {
                System.out.println("我在run方法里面，当前线程的状态是："+ Thread.currentThread().getState() + Thread.currentThread().getId());
                Thread.sleep(3000);
            } catch (Exception e) {
            }
        });
        System.out.println("t1 线程还没有执行start方法时的线程状态是："+t1.getState());
        t1.start();
        System.out.println("t1 执行start方法时的线程状态是："+t1.getState());
        t1.join();
        System.out.println("主线程的线程状态："+ Thread.currentThread().getState());
        System.out.println("t1 执行join方法之后的线程状态是："+ t1.getState());
        Thread.sleep(3000);
        System.out.println("t1 执行join方法之后sleep(3000)的线程状态是："+ t1.getState());

    }
}
